<?php

namespace Drupal\shushengyuan\Schemas;

/**
 * @OA\Schema(
 *   schema="File",
 *   type="object",
 *   description="File"
 * )
 */
class File extends AbstractBaseModel {

  protected function getEntityType() {
    return 'file';
  }

  protected function setValue() {
    $value = [
      /**
       * @OA\Property(
       *   property="id",
       *   type="integer",
       *   description="ID",
       * ),
       */
      'id' => $this->entity->fid,
      /**
       * @OA\Property(
       *   property="name",
       *   type="string",
       *   description="文件名",
       * ),
       */
      'name' => $this->entity->filename,
      /**
       * @OA\Property(
       *   property="url",
       *   type="string",
       *   description="访问URL",
       * ),
       */
      'url' => file_create_url($this->entity->uri),
    ];
    $this->merge($value);
  }
}
